import apiClient from '@/api/apiClient.ts';
import { Page } from '#/api.ts';
import { MaintenancePlanInfo } from '#/entity.ts';

export enum MaintenancePlanApi {
  GetList = '/roadCure/curePlan/getCurePlanList',
  GetDetail = '/roadCure/curePlan/getCurePlanDetails',
  Delay = '/roadCure/curePlan/delayCurePlan',
}

export interface MaintenancePlanListParams {
  alarmDesc?: string;
  alarmTime?: string;
  carNoList?: string[];
  departmentId?: number;
  dealWithStatus?: string;
  reportPosition?: string;
}

export interface DelayParams {
  id: number;
  delayTime: string;
  delayReason: string;
  delayRemark?: string;
}

const getList = (data: MaintenancePlanListParams & Page) =>
  apiClient.post<MaintenancePlanInfo[]>({
    url: MaintenancePlanApi.GetList,
    data,
  });

const getDetail = (id: number) =>
  apiClient.get<MaintenancePlanInfo>({
    url: MaintenancePlanApi.GetDetail,
    params: { id },
  });

const delay = (data: DelayParams) =>
  apiClient.put({
    url: MaintenancePlanApi.Delay,
    data,
  });

export default {
  getList,
  getDetail,
  delay,
};
